package com.shop.admin.controller;

import com.shop.Result.LdbzResult;
import com.shop.admin.service.AdminSheetService;
import com.shop.pojo.LdbzSheet;
import com.shop.pojo.LdbzSheetAssign;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/admin/sheet/service")
public class AdminSheetController {

    private static final Logger logger = LoggerFactory.getLogger(AdminSheetController.class);

    @Autowired
    private AdminSheetService adminSheetService;

    @RequestMapping(value="/editSheet/{id}" , method = RequestMethod.GET)
    public LdbzResult editSheet(@PathVariable("id")long id , Model model) {
        return adminSheetService.selectByKey(id);
    }

    @RequestMapping(value="/getSheetList" , method = RequestMethod.GET)
    public LdbzResult getSheetList(LdbzSheet entity) {
        return adminSheetService.getSheetList(entity);
    }

    @RequestMapping(value="/getSheetPage" , method = RequestMethod.GET)
    public LdbzResult getSheetPage(LdbzSheet entity , int page , int limit) {
        return adminSheetService.getSheetPage(entity, page, limit);
    }

    @RequestMapping(value="/updateByKey" , method = RequestMethod.GET)
    public LdbzResult updateByKey(LdbzSheet entity) {
        return adminSheetService.updateByKey(entity);
    }

    @RequestMapping(value="/assignSheet/{id}" , method = RequestMethod.GET)
    public LdbzResult assignSheet(@PathVariable("id")String id , Model model) {
        return adminSheetService.selectByKey(Long.valueOf(id));
    }

    @RequestMapping(value="/getSheetAssignList/{id}" , method = RequestMethod.GET)
    public LdbzResult getSheetAssignList(@PathVariable("id")long sheetId) {
        return adminSheetService.getSheetAssign(sheetId);
    }

    @RequestMapping(value="/deleteAssign/{id}" , method = RequestMethod.GET)
    public LdbzResult deleteAssign(@PathVariable("id")String id) {
        return adminSheetService.deleteAssign(id);
    }

    @RequestMapping(value="/addAssign" , method = RequestMethod.GET)
    public LdbzResult addAssign(LdbzSheetAssign entity) {
        return adminSheetService.addAssign(entity);
    }
}
